cmake_minimum_required(VERSION 3.15)

set(projectName demo)

project(${projectName})

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-pthread")

include_directories(
  ${PROJECT_SOURCE_DIR}/../source/executor/inc
  ${PROJECT_SOURCE_DIR}/../source/plat/comm
  ${PROJECT_SOURCE_DIR}/../source/plat/stack
  ${PROJECT_SOURCE_DIR}/../source/plat/linklist
  ${PROJECT_SOURCE_DIR}/../source/exam/inc
  ${PROJECT_SOURCE_DIR}/../source/prac/inc
  ${PROJECT_SOURCE_DIR}/../source/routes/inc
  ${PROJECT_SOURCE_DIR}/../source/core/inc
  ${PROJECT_SOURCE_DIR}/../source/leetcode/inc
  ${PROJECT_SOURCE_DIR}/../source/codekata/inc
  ${PROJECT_SOURCE_DIR}/../source
  ${PROJECT_SOURCE_DIR}/../source/pub_inc
  ${PROJECT_SOURCE_DIR}/../test/inc
  ${PROJECT_SOURCE_DIR}/../third/inc)

list(
  APPEND
  UT_SRC_FILES
  src/executor.cpp
  src/executor_test.cpp
  src/ds_stack_test.cpp
  src/ds_linklist_test.cpp
  src/exam_test.cpp
  src/prac_test.cpp
  src/prac_mockcpp.cpp
  src/routes_test.cpp
  src/core_test.cpp
  src/leetcode_test.cpp
  src/codekata_test.cpp
  src/statistics_test.cpp
)

list(
  APPEND
  UT_EXE_FILES
  ut_executor
  ut_executor_test
  ut_ds_stack
  ut_ds_linklist
  ut_exam_test
  ut_prac_test
  ut_prac_mockcpp_test
  ut_routes_test
  ut_core_test
  ut_leetcode_test
  ut_codekata_test
  ut_statistics_test
  )

# for gcov
if(ENABLE_COVERAGE)
  message(STATUS "Use gcov for code coverage test")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
endif()

link_directories(${PROJECT_SOURCE_DIR}/../third/lib
                 ${PROJECT_SOURCE_DIR}/../output/lib)

add_compile_options(-g)

foreach(ut_exe ut_src IN ZIP_LISTS UT_EXE_FILES UT_SRC_FILES)
  message(STATUS "ut_src = ${ut_src}")
  message(STATUS "ut_exe = ${ut_exe}")

  add_executable(${ut_exe} ${ut_src})
  target_link_libraries(
    ${ut_exe}
    libgtest.a
    libgtest_main.a
    libgmock.a
    libgmock_main.a
    libmockcpp.a
    pthread
    ds
    executor
    exam
    prac
    routes
    core
    leetcode
    codekata)
endforeach()
